<?php
require('../config.php');
		$start=0;
		$num=10;
		if(isset($_REQUEST['start'])) $start=$_REQUEST['start'];
		if(isset($_REQUEST['num'])) $num=$_REQUEST['num'];
		$sql="select s.id,s.sid,s.shop_id,s.title,s.qishu,s.q_uid,s.thumb,s.q_end_time,s.q_user_code from `".$oto."_shoplist` as s where `q_uid` is not null and `q_showtime` = 'N' ORDER BY `q_end_time` DESC limit $start,$num";
		$result=$db->query($sql);
		while($row=$result->fetch_assoc()){
			$zxjx_list[]=$row;//将取得的所有数据赋值给person_info数组
		}
		if(isset($zxjx_list))
		{
			for($i=0;$i<count($zxjx_list);$i++)
			{
				$xsd=explode('.',$zxjx_list[$i]['q_end_time']);
				if(count($xsd)>1) $xsd=$xsd[1];
				else $xsd=$xsd[0];
				$zxjx_list[$i]['jx_time']=date('Y-m-d H:i:s',$zxjx_list[$i]['q_end_time']).'.'.$xsd;
				$user_id=$zxjx_list[$i]['q_uid'];
				$shopid=$zxjx_list[$i]['id'];
				$sql="select sum(`gonumber`) as gonumber from `".$oto."_member_go_record` where `uid` ='{$user_id}'  and `shopid`='{$shopid}' ";
				$result=$db->query($sql);
				while($row=$result->fetch_assoc()){
					$member_go_record_list[$i]=$row;//将取得的所有数据赋值给person_info数组
				}
				$sql="select * from `".$oto."_users` where `userId`='{$user_id}'";
				$result=$db->query($sql);
				while($row=$result->fetch_assoc()){
					$users[$i]=$row;//将取得的所有数据赋值给person_info数组
				}

				if(isset($member_go_record_list[$i]))
				{
					$zxjx_list[$i]['gonumber']=$member_go_record_list[$i]['gonumber'];
				}
				else $zxjx_list[$i]['gonumber']=1;
				if(isset($users[$i]))
				{
					$zxjx_list[$i]['userName']=$users[$i]['userName'];
					$zxjx_list[$i]['userPhoto']=$users[$i]['userPhoto'];
				} 
				else 
				{
					$zxjx_list[$i]['userName']="";
					$zxjx_list[$i]['userPhoto']="";
				}
				$sid=$zxjx_list[$i]['sid'];
				//获取期数
				$sql="select s.qishu from `".$oto."_shoplist` as s where sid='{$sid}' order by qishu desc limit 1";
				$result=$db->query($sql);
				while($row=$result->fetch_assoc()){
					$qishu_info=$row;
				}
				if(isset($qishu_info)) $zxjx_list[$i]['max_qishu']=$qishu_info['qishu'];
				else $zxjx_list[$i]['max_qishu']="";
			}
			echo json_encode($zxjx_list);
		}
		else 
		{
			echo '[]';
		}
?>